/*
* Configuration of module: Dcm
*
* Created by:   qinminyuan
* Copyright:    (C)  
*
* Configured for (MCU):    MCU
*
* Module vendor:           ArcCore
* Generator version:       01.00
*/
#ifdef USE_DCM
#include "Std_Types.h"
#include "Dcm.h"
#include "Dcm_Internal.h"
#if defined(USE_PDUR)
#include "PduR.h"
#endif

#define INDEX_OF_SECURITY_Security_level3                  0
//#define DCM_SECURITY_EOL_INDEX 1

#define INDEX_OF_SESSION_Default                          0
#define INDEX_OF_SESSION_Program                          1
#define INDEX_OF_SESSION_Extend                           2
#define DCM_SESSION_EOL_INDEX 3

#define INDEX_OF_DIDINFO_DIDInfo_F180                     0
#define INDEX_OF_DIDINFO_DIDInfo_F184                     1
#define INDEX_OF_DIDINFO_DIDInfo_F187                     2
#define INDEX_OF_DIDINFO_DIDInfo_F089                     3
#define INDEX_OF_DIDINFO_DIDInfo_F013                     4
#define INDEX_OF_DIDINFO_DIDInfo_F18A                     5
#define INDEX_OF_DIDINFO_DIDInfo_F0F3                     6
#define DCM_DID_LIST_EOL_INDEX 7

#define INDEX_OF_RCINFO_RoutineInfo_checkProgramPreconditions 0
#define INDEX_OF_RCINFO_RoutineInfo_eraseMemory          1
#define INDEX_OF_RCINFO_RoutineInfo_chechProgramDependencies 2
#define INDEX_OF_RCINFO_RoutineInfo_StayInBoot           3
#define INDEX_OF_RCINFO_RoutineInfo_SecuritySignatureVerification 4

#define INDEX_OF_BUF_vDcmRxBuffer                     0
#define INDEX_OF_BUF_vDcmTxBuffer                     1

#define INDEX_OF_TL_Timing1                          0

#define INDEX_OF_ST_ServiceTable1                    0

extern Std_ReturnType DIDF180_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF180_ReadCbk(uint8 *data);
extern Std_ReturnType DIDF184_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF184_ReadCbk(uint8 *data);
extern Std_ReturnType DIDF184_WriteConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF184_WriteCbk(uint8 *data, uint16 dataLength, Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF187_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF187_ReadCbk(uint8 *data);
extern Std_ReturnType DIDF089_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF089_ReadCbk(uint8 *data);
extern Std_ReturnType DIDF013_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF013_ReadCbk(uint8 *data);
extern Std_ReturnType DIDF18A_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF18A_ReadCbk(uint8 *data);
extern Std_ReturnType DIDF0F3_ReadConditionCheckCbk(Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType DIDF0F3_ReadCbk(uint8 *data);
/* --------------------------------------------------------- */

extern Std_ReturnType Security_GetSeed_Level3 (uint8 *securityAccessDataRecord, uint8 *seed, Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType Security_CompKey_Level3 (uint8 *key);
extern Std_ReturnType Diag_StartProtocolCbk (Dcm_ProtocolType protocolID);
extern Std_ReturnType Diag_StopProtocolCbk (Dcm_ProtocolType protocolID);
extern Std_ReturnType Diag_GetSessionChangePermissionCbk(Dcm_SesCtrlType sesCtrlTypeActive, Dcm_SesCtrlType sesCtrlTypeNew);
extern Std_ReturnType checkProgramPreconditions0203_StartCbk(uint8 *inBuffer, uint8 *outBuffer, Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType eraseMemoryFF00_StartCbk(uint8 *inBuffer, uint8 *outBuffer, Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType chechProgramDependenciesFF01_StartCbk(uint8 *inBuffer, uint8 *outBuffer, Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType StayInBootDD01_StartCbk(uint8 *inBuffer, uint8 *outBuffer, Dcm_NegativeResponseCodeType *errorCode);
extern Std_ReturnType SecuritySignatureVerificationDD02_StartCbk(uint8 *inBuffer, uint8 *outBuffer, Dcm_NegativeResponseCodeType *errorCode);
static const Dcm_DspSecurityRowType DspSecurityList[] = {
	{ // Security_level3 ,0
		.DspSecurityLevel           =  9,
		.DspSecurityDelayTimeOnBoot =  0,/* Value is not configurable */
		.DspSecurityNumAttDelay     =  2,
		.DspSecurityDelayTime       =  10000,
		.DspSecurityNumAttLock      =  0,     /* Value is not configurable */
		.DspSecurityADRSize         =  0, // TODO:
		.DspSecuritySeedSize        =  16,
		.DspSecurityKeySize         =  16,
		.GetSeed                    =  Security_GetSeed_Level3,
		.CompareKey                 =  Security_CompKey_Level3,
		.Arc_EOL                    =  FALSE
	},
	{ 
		.Arc_EOL = TRUE
	}
};

static const Dcm_DspSecurityType DspSecurity = {
    .DspSecurityRow = DspSecurityList
};

static const Dcm_DspSessionRowType DspSessionList[] = {
	{ //Default
		.DspSessionLevel           = 1,
		.DspSessionP2ServerMax     = 50,
		.DspSessionP2StarServerMax =  5000,
		.Arc_EOL                   =  FALSE
	},
	{ //Program
		.DspSessionLevel           = 2,
		.DspSessionP2ServerMax     = 25,
		.DspSessionP2StarServerMax =  5000,
		.Arc_EOL                   =  FALSE
	},
	{ //Extend
		.DspSessionLevel           = 3,
		.DspSessionP2ServerMax     = 50,
		.DspSessionP2StarServerMax =  5000,
		.Arc_EOL                   =  FALSE
	},
	{ 
		.Arc_EOL = TRUE
	},
};

static const Dcm_DspSessionType DspSession = {
    .DspSessionRow = DspSessionList,
};

const Dcm_DspSecurityRowType *SecurityList_Security_level3[] = {
	&DspSecurityList[INDEX_OF_SECURITY_Security_level3],
	&DspSecurityList[DCM_SECURITY_EOL_INDEX]
};
static const Dcm_DspSessionRowType *SessionList_Default_Extend_Program[] = {
	&DspSessionList[INDEX_OF_SESSION_Default],
	&DspSessionList[INDEX_OF_SESSION_Extend],
	&DspSessionList[INDEX_OF_SESSION_Program],
	&DspSessionList[DCM_SESSION_EOL_INDEX]
};
static const Dcm_DspSessionRowType *SessionList_Program[] = {
	&DspSessionList[INDEX_OF_SESSION_Program],
	&DspSessionList[DCM_SESSION_EOL_INDEX]
};
static const Dcm_DspSessionRowType *SessionList_Extend_Program[] = {
	&DspSessionList[INDEX_OF_SESSION_Extend],
	&DspSessionList[INDEX_OF_SESSION_Program],
	&DspSessionList[DCM_SESSION_EOL_INDEX]
};

static const Dcm_DspDidReadType DIDInfo_F180_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidReadType DIDInfo_F184_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidWriteType DIDInfo_F184_didWrite = {
    .DspDidWriteSessionRef =  SessionList_Program,
    .DspDidWriteSecurityLevelRef =  SecurityList_Security_level3
};

static const Dcm_DspDidReadType DIDInfo_F187_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidReadType DIDInfo_F089_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidReadType DIDInfo_F013_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidReadType DIDInfo_F18A_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidReadType DIDInfo_F0F3_didRead = {
    .DspDidReadSessionRef =  SessionList_Default_Extend_Program,
    .DspDidReadSecurityLevelRef =  NULL
};

static const Dcm_DspDidInfoType DspDidInfoList[] = {
	{ // DIDInfo_F180 ,0
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F180_didRead,
			.DspDidWrite   = NULL,
			.DspDidControl = NULL,
		}
	}, 
	{ // DIDInfo_F184 ,1
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F184_didRead,
			.DspDidWrite   = &DIDInfo_F184_didWrite,
			.DspDidControl = NULL,
		}
	}, 
	{ // DIDInfo_F187 ,2
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F187_didRead,
			.DspDidWrite   = NULL,
			.DspDidControl = NULL,
		}
	}, 
	{ // DIDInfo_F089 ,3
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F089_didRead,
			.DspDidWrite   = NULL,
			.DspDidControl = NULL,
		}
	}, 
	{ // DIDInfo_F013 ,4
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F013_didRead,
			.DspDidWrite   = NULL,
			.DspDidControl = NULL,
		}
	}, 
	{ // DIDInfo_F18A ,5
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F18A_didRead,
			.DspDidWrite   = NULL,
			.DspDidControl = NULL,
		}
	}, 
	{ // DIDInfo_F0F3 ,6
		.DspDidDynamicllyDefined =  False,
		.DspDidFixedLength       =  True,
		.DspDidScalingInfoSize   =  0,
		.DspDidAccess = {
			.DspDidRead    = &DIDInfo_F0F3_didRead,
			.DspDidWrite   = NULL,
			.DspDidControl = NULL,
		}
	}, 
};

extern const Dcm_DspDidType DspDidList[];
static const Dcm_DspDidType* DIDF180_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
static const Dcm_DspDidType* DIDF184_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
static const Dcm_DspDidType* DIDF187_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
static const Dcm_DspDidType* DIDF089_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
static const Dcm_DspDidType* DIDF013_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
static const Dcm_DspDidType* DIDF18A_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
static const Dcm_DspDidType* DIDF0F3_dididRefList[] =
{    // TODO
&DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};
const Dcm_DspDidType DspDidList[] = { 
	{ // DIDF180, 0
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF180,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F180],
		.DspDidRef                    =  DIDF180_dididRefList,
		.DspDidSize                   =  32,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF180_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF180_ReadCbk,
		.DspDidConditionCheckWriteFnc =  NULL,
		.DspDidWriteDataFnc           =  NULL,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ // DIDF184, 1
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF184,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F184],
		.DspDidRef                    =  DIDF184_dididRefList,
		.DspDidSize                   =  19,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF184_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF184_ReadCbk,
		.DspDidConditionCheckWriteFnc =  DIDF184_WriteConditionCheckCbk,
		.DspDidWriteDataFnc           =  DIDF184_WriteCbk,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ // DIDF187, 2
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF187,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F187],
		.DspDidRef                    =  DIDF187_dididRefList,
		.DspDidSize                   =  16,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF187_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF187_ReadCbk,
		.DspDidConditionCheckWriteFnc =  NULL,
		.DspDidWriteDataFnc           =  NULL,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ // DIDF089, 3
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF089,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F089],
		.DspDidRef                    =  DIDF089_dididRefList,
		.DspDidSize                   =  24,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF089_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF089_ReadCbk,
		.DspDidConditionCheckWriteFnc =  NULL,
		.DspDidWriteDataFnc           =  NULL,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ // DIDF013, 4
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF013,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F013],
		.DspDidRef                    =  DIDF013_dididRefList,
		.DspDidSize                   =  16,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF013_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF013_ReadCbk,
		.DspDidConditionCheckWriteFnc =  NULL,
		.DspDidWriteDataFnc           =  NULL,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ // DIDF18A, 5
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF18A,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F18A],
		.DspDidRef                    =  DIDF18A_dididRefList,
		.DspDidSize                   =  10,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF18A_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF18A_ReadCbk,
		.DspDidConditionCheckWriteFnc =  NULL,
		.DspDidWriteDataFnc           =  NULL,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ // DIDF0F3, 6
		.DspDidUsePort                =  DATA_PORT_SYNCH,
		.DspDidIdentifier             =  0xF0F3,
		.DspDidInfoRef                =  &DspDidInfoList[INDEX_OF_DIDINFO_DIDInfo_F0F3],
		.DspDidRef                    =  DIDF0F3_dididRefList,
		.DspDidSize                   =  4,
		.DspDidReadDataLengthFnc      =  NULL,
		.DspDidConditionCheckReadFnc  =  DIDF0F3_ReadConditionCheckCbk,
		.DspDidReadDataFnc            =  DIDF0F3_ReadCbk,
		.DspDidConditionCheckWriteFnc =  NULL,
		.DspDidWriteDataFnc           =  NULL,
		.DspDidGetScalingInfoFnc      =  NULL,
		.DspDidFreezeCurrentStateFnc  =  NULL,
		.DspDidResetToDefaultFnc      =  NULL,
		.DspDidReturnControlToEcuFnc  =  NULL,
		.DspDidShortTermAdjustmentFnc =  NULL,
		.DspDidControlRecordSize      =  NULL,
		.Arc_EOL                      =  FALSE
	},
	{ 		.Arc_EOL =  TRUE
	}
};

/************************************************************************
*                            Routine control                                *
************************************************************************/

static const Dcm_DspStartRoutineType RoutineInfo_checkProgramPreconditions_start = {
    .DspStartRoutineCtrlOptRecSize = 0,
    .DspStartRoutineStsOptRecSize =  1
};
static const Dcm_DspSessionRowType *SessionList_Extend[] = {
	&DspSessionList[INDEX_OF_SESSION_Extend],
	&DspSessionList[DCM_SESSION_EOL_INDEX]
};
static const Dcm_DspStartRoutineType RoutineInfo_eraseMemory_start = {
    .DspStartRoutineCtrlOptRecSize = 9,
    .DspStartRoutineStsOptRecSize =  1
};
static const Dcm_DspStartRoutineType RoutineInfo_chechProgramDependencies_start = {
    .DspStartRoutineCtrlOptRecSize = 0,
    .DspStartRoutineStsOptRecSize =  1
};
static const Dcm_DspStartRoutineType RoutineInfo_StayInBoot_start = {
    .DspStartRoutineCtrlOptRecSize = 0,
    .DspStartRoutineStsOptRecSize =  1
};
static const Dcm_DspSessionRowType *SessionList_Default[] = {
	&DspSessionList[INDEX_OF_SESSION_Default],
	&DspSessionList[DCM_SESSION_EOL_INDEX]
};
static const Dcm_DspStartRoutineType RoutineInfo_SecuritySignatureVerification_start = {
    .DspStartRoutineCtrlOptRecSize = 384,
    .DspStartRoutineStsOptRecSize =  1
};
static const Dcm_DspRoutineInfoType DspRoutineInfoList[] = {
	{//RoutineInfo_checkProgramPreconditions
		.DspRoutineAuthorization={
			.DspRoutineSessionRef       =  SessionList_Extend,
			.DspRoutineSecurityLevelRef = NULL,
		},
		.DspStartRoutine = &RoutineInfo_checkProgramPreconditions_start,
		.DspRoutineStop =  NULL,
		.DspRoutineRequestRes =  NULL
	},
	{//RoutineInfo_eraseMemory
		.DspRoutineAuthorization={
			.DspRoutineSessionRef       =  SessionList_Program,
			.DspRoutineSecurityLevelRef = SecurityList_Security_level3,
		},
		.DspStartRoutine = &RoutineInfo_eraseMemory_start,
		.DspRoutineStop =  NULL,
		.DspRoutineRequestRes =  NULL
	},
	{//RoutineInfo_chechProgramDependencies
		.DspRoutineAuthorization={
			.DspRoutineSessionRef       =  SessionList_Program,
			.DspRoutineSecurityLevelRef = SecurityList_Security_level3,
		},
		.DspStartRoutine = &RoutineInfo_chechProgramDependencies_start,
		.DspRoutineStop =  NULL,
		.DspRoutineRequestRes =  NULL
	},
	{//RoutineInfo_StayInBoot
		.DspRoutineAuthorization={
			.DspRoutineSessionRef       =  SessionList_Default,
			.DspRoutineSecurityLevelRef = NULL,
		},
		.DspStartRoutine = &RoutineInfo_StayInBoot_start,
		.DspRoutineStop =  NULL,
		.DspRoutineRequestRes =  NULL
	},
	{//RoutineInfo_SecuritySignatureVerification
		.DspRoutineAuthorization={
			.DspRoutineSessionRef       =  SessionList_Program,
			.DspRoutineSecurityLevelRef = SecurityList_Security_level3,
		},
		.DspStartRoutine = &RoutineInfo_SecuritySignatureVerification_start,
		.DspRoutineStop =  NULL,
		.DspRoutineRequestRes =  NULL
	},
	{
		.DspRoutineAuthorization={
			.DspRoutineSessionRef       =  NULL,
			.DspRoutineSecurityLevelRef = NULL,
		},
		.DspStartRoutine      =  NULL,
		.DspRoutineStop       =  NULL,
		.DspRoutineRequestRes =  NULL,
	}
};

static const Dcm_DspRoutineType  DspRoutineList[] = {
	{//Routine_checkProgramPreconditions
		.DspRoutineUsePort = FALSE,
		.DspRoutineIdentifier = 0x0203,
		.DspRoutineInfoRef = &DspRoutineInfoList[INDEX_OF_RCINFO_RoutineInfo_checkProgramPreconditions],
		.DspStartRoutineFnc = checkProgramPreconditions0203_StartCbk,
		.DspStopRoutineFnc =  NULL,
		.DspRequestResultRoutineFnc =  NULL,
		.Arc_EOL = FALSE
	},
	{//Routine_eraseMemory
		.DspRoutineUsePort = FALSE,
		.DspRoutineIdentifier = 0xFF00,
		.DspRoutineInfoRef = &DspRoutineInfoList[INDEX_OF_RCINFO_RoutineInfo_eraseMemory],
		.DspStartRoutineFnc = eraseMemoryFF00_StartCbk,
		.DspStopRoutineFnc =  NULL,
		.DspRequestResultRoutineFnc =  NULL,
		.Arc_EOL = FALSE
	},
	{//Routine_chechProgramDependencies
		.DspRoutineUsePort = FALSE,
		.DspRoutineIdentifier = 0xFF01,
		.DspRoutineInfoRef = &DspRoutineInfoList[INDEX_OF_RCINFO_RoutineInfo_chechProgramDependencies],
		.DspStartRoutineFnc = chechProgramDependenciesFF01_StartCbk,
		.DspStopRoutineFnc =  NULL,
		.DspRequestResultRoutineFnc =  NULL,
		.Arc_EOL = FALSE
	},
	{//Routine_StayInBoot
		.DspRoutineUsePort = FALSE,
		.DspRoutineIdentifier = 0xDD01,
		.DspRoutineInfoRef = &DspRoutineInfoList[INDEX_OF_RCINFO_RoutineInfo_StayInBoot],
		.DspStartRoutineFnc = StayInBootDD01_StartCbk,
		.DspStopRoutineFnc =  NULL,
		.DspRequestResultRoutineFnc =  NULL,
		.Arc_EOL = FALSE
	},
	{//Routine_SecuritySignatureVerification
		.DspRoutineUsePort = FALSE,
		.DspRoutineIdentifier = 0xDD02,
		.DspRoutineInfoRef = &DspRoutineInfoList[INDEX_OF_RCINFO_RoutineInfo_SecuritySignatureVerification],
		.DspStartRoutineFnc = SecuritySignatureVerificationDD02_StartCbk,
		.DspStopRoutineFnc =  NULL,
		.DspRequestResultRoutineFnc =  NULL,
		.Arc_EOL = FALSE
	},
	{
		.DspRoutineUsePort          = FALSE,
		.DspRoutineIdentifier       = 0xFFFF,
		.DspRoutineInfoRef          = NULL,
		.DspStartRoutineFnc         = NULL,
		.DspStopRoutineFnc          = NULL,
		.DspRequestResultRoutineFnc = NULL,
		.Arc_EOL                    = TRUE
	}
};

/************************************************************************
*                            Memory Info                                 *
************************************************************************/

static const Dcm_DspType Dsp = {
    .DspMaxDidToRead       =  0xDB, // TODO
    .DspDid                =  DspDidList,
    .DspDidInfo            =  DspDidInfoList,
    .DspEcuReset           =  NULL,
    .DspPid                =  NULL,
    .DspReadDTC            =  NULL,
    .DspRequestControl     =  NULL,
    .DspRoutine            =  DspRoutineList,
    .DspRoutineInfo        =  DspRoutineInfoList,
    .DspSecurity           =  &DspSecurity,
    .DspSession            =  &DspSession,
    .DspTestResultByObdmid =  NULL,
    .DspVehInfo            =  NULL,
    .DspMemory             =  NULL
};

/************************************************************************
*                                    DSD                                    *
************************************************************************/

static const Dcm_DsdServiceType ServiceTable1_serviceList[] = {
	{ 
		.DsdSidTabServiceId        = SID_DIAGNOSTIC_SESSION_CONTROL,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Default_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_ECU_RESET,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Default_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_READ_DATA_BY_IDENTIFIER,
		.DsdSidTabSubfuncAvail     = FALSE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Default_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_SECURITY_ACCESS,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_WRITE_DATA_BY_IDENTIFIER,
		.DsdSidTabSubfuncAvail     = FALSE,
		.DsdSidTabSecurityLevelRef = SecurityList_Security_level3,
		.DsdSidTabSessionLevelRef  = SessionList_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_ROUTINE_CONTROL,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_REQUEST_DOWNLOAD,
		.DsdSidTabSubfuncAvail     = FALSE,
		.DsdSidTabSecurityLevelRef = SecurityList_Security_level3,
		.DsdSidTabSessionLevelRef  = SessionList_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_TRANSFER_DATA,
		.DsdSidTabSubfuncAvail     = FALSE,
		.DsdSidTabSecurityLevelRef = SecurityList_Security_level3,
		.DsdSidTabSessionLevelRef  = SessionList_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_REQUEST_TRANSFER_EXIT,
		.DsdSidTabSubfuncAvail     = FALSE,
		.DsdSidTabSecurityLevelRef = SecurityList_Security_level3,
		.DsdSidTabSessionLevelRef  = SessionList_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_TESTER_PRESENT,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Default_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_CONTROL_DTC_SETTING,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.DsdSidTabServiceId        = SID_COMMUNICATION_CONTROL,
		.DsdSidTabSubfuncAvail     = TRUE,
		.DsdSidTabSecurityLevelRef = NULL,
		.DsdSidTabSessionLevelRef  = SessionList_Extend_Program,
		.Arc_EOL = FALSE
	},
	{ 
		.Arc_EOL = TRUE
	}
};

static const Dcm_DsdServiceTableType DsdServiceTable[] = {    
	{ // ServiceTable1
		.DsdSidTabId = 0,
		.DsdService = ServiceTable1_serviceList,
		.Arc_EOL = FALSE
	},
	{ 
		.Arc_EOL = TRUE
	}
};

static const Dcm_DsdType Dsd = {
    .DsdServiceTable = DsdServiceTable
};

/************************************************************************
*                                    DSL                                    *
************************************************************************/

static uint8 vDcmRxBuffer[2048];
Dcm_DslBufferRuntimeType rxBufferParams_vDcmRxBuffer =
{
    .status =  BUFFER_AVAILABLE
};
static uint8 vDcmTxBuffer[512];
Dcm_DslBufferRuntimeType rxBufferParams_vDcmTxBuffer =
{
    .status =  BUFFER_AVAILABLE
};
static const Dcm_DslBufferType DcmDslBufferList[DCM_DSL_BUFFER_LIST_LENGTH] = {
	{
		.DslBufferID   =  0,// TODO
		.DslBufferSize = 2048,/* ?Value is not configurable */
		.pduInfo={
			.SduDataPtr = vDcmRxBuffer,
			.SduLength  =  2048,
		},
		.externalBufferRuntimeData = &rxBufferParams_vDcmRxBuffer
	},
	{
		.DslBufferID   =  1,// TODO
		.DslBufferSize = 512,/* ?Value is not configurable */
		.pduInfo={
			.SduDataPtr = vDcmTxBuffer,
			.SduLength  =  512,
		},
		.externalBufferRuntimeData = &rxBufferParams_vDcmTxBuffer
	},
};

static const Dcm_DslCallbackDCMRequestServiceType DCMRequestServiceList[] = {
	{ // RequestService1
		.StartProtocol = Diag_StartProtocolCbk,
		.StopProtocol  = Diag_StopProtocolCbk,
		.Arc_EOL       = FALSE
	},
	{
		.Arc_EOL = TRUE
	}
};

static const Dcm_DslServiceRequestIndicationType DCMServiceRequestIndicationList[] = {
	{ 
		.Arc_EOL = TRUE
	}
};

extern const Dcm_DslMainConnectionType DslMainConnectionList[];

static const Dcm_DslProtocolRxType DcmDslProtocolRxList[] = {
	{// Protocol1->Connection1->vRxPhys
		.DslMainConnectionParent      =  &DslMainConnectionList[0],
		.DslProtocolAddrType          =  DCM_PROTOCOL_PHYSICAL_ADDR_TYPE,
		.DcmDslProtocolRxPduId        =  PDUR_ID_Phys_DiagRx,
		.DcmDslProtocolRxChannelId_v4 =  0,       /* Value is not configurable */
		.DcmDslProtocolRxComMChannel  =  0,                /* Value is not configurable */
		.Arc_EOL                      =  FALSE
	},
	{// Protocol1->Connection1->vRxFunc
		.DslMainConnectionParent      =  &DslMainConnectionList[0],
		.DslProtocolAddrType          =  DCM_PROTOCOL_FUNCTIONAL_ADDR_TYPE,
		.DcmDslProtocolRxPduId        =  PDUR_ID_Func_DiagRx,
		.DcmDslProtocolRxChannelId_v4 =  0,       /* Value is not configurable */
		.DcmDslProtocolRxComMChannel  =  0,                /* Value is not configurable */
		.Arc_EOL                      =  FALSE
	},
	{
		.Arc_EOL = TRUE
	}
};

static const Dcm_DslProtocolTxType DcmDslProtocolTxList[] = {
	{// Protocol1->Connection1->vTxPhysCan0
		.DslMainConnectionParent  =  &DslMainConnectionList[0],
		.DcmDslProtocolTxPduId    =  PDUR_ID_Phys_DiagTx,
		.DcmDslProtocolDcmTxPduId =  DCM_ID_Phys_DiagTx,
		.Arc_EOL                  =  FALSE
	},
	{
		.Arc_EOL = TRUE
	}
};

extern const Dcm_DslConnectionType DslConnectionList[];

const Dcm_DslMainConnectionType DslMainConnectionList[] = {
	{//Protocol1->Connection1
		.DslConnectionParent           =  &DslConnectionList[0],
		.DslPeriodicTransmissionConRef =  NULL,        /* Value is not configurable */
		.DslROEConnectionRef           =  NULL,                /* Value is not configurable */
		.DslProtocolRx                 =  NULL,                        /* Value is not configurable */
		.DslProtocolTx                 =  &DcmDslProtocolTxList[0],
	},
};

extern const Dcm_DslProtocolRowType DslProtocolRowList[];

const Dcm_DslConnectionType DslConnectionList[] = {
	{//Protocol1->Connection1
		.DslProtocolRow          = &DslProtocolRowList[0],
		.DslMainConnection       = &DslMainConnectionList[0],
		.DslPeriodicTransmission = NULL,    /* Value is not configurable */
		.DslResponseOnEvent      = NULL,    /* Value is not configurable */
		.Arc_EOL                 =  FALSE
	},
	{
		.Arc_EOL = TRUE
	}
};

extern const Dcm_DslProtocolTimingRowType ProtocolTimingList[];

static Dcm_DslRunTimeProtocolParametersType dcmDslRuntimeVariables[1];
const Dcm_DslProtocolRowType DslProtocolRowList[]= {
	{//Protocol1
		.DslProtocolID                 = DCM_UDS_ON_CAN,
		.DslProtocolIsParallelExecutab = FALSE, // not supported
		.DslProtocolPreemptTimeout     = 0,    // not supported
		.DslProtocolPriority           = 0,    // not supported
		.DslProtocolTransType          = DCM_PROTOCOL_TRANS_TYPE_1,
		.DslProtocolRxBufferID         = &DcmDslBufferList[INDEX_OF_BUF_vDcmRxBuffer],
		.DslProtocolTxBufferID         = &DcmDslBufferList[INDEX_OF_BUF_vDcmTxBuffer],
		.DslProtocolSIDTable           = &DsdServiceTable[INDEX_OF_ST_ServiceTable1],
		.DslProtocolTimeLimit          = &ProtocolTimingList[INDEX_OF_TL_Timing1],
		.DslConnection                 =  DslConnectionList,
		.DslRunTimeProtocolParameters  = &dcmDslRuntimeVariables[0],
		.Arc_EOL                       = FALSE
	},
	{
		.Arc_EOL = TRUE
	}
};

static const Dcm_DslProtocolType DslProtocol = {
    .DslProtocolRxGlobalList = DcmDslProtocolRxList,
    .DslProtocolTxGlobalList = DcmDslProtocolTxList,
    .DslProtocolRowList = DslProtocolRowList
};

const Dcm_DslProtocolTimingRowType ProtocolTimingList[] = {
	{//Timing1
		.TimStrP2ServerMax     = 5000,
		.TimStrP2ServerMin     = 50,
		.TimStrP2StarServerMax = 0,        /* Value is not configurable */
		.TimStrP2StarServerMin = 0,        /* Value is not configurable */
		.TimStrS3Server        = 5000,
		.Arc_EOL               = FALSE
	},
	{
		.Arc_EOL =  TRUE
	},
};

static const Dcm_DslProtocolTimingType ProtocolTiming = {
    .DslProtocolTimingRow = ProtocolTimingList
};

static const Dcm_DslSessionControlType SessionControlList[] = {
	{//SessionControl1
		.GetSesChgPermission  = Diag_GetSessionChangePermissionCbk,
		.ChangeIndication     = NULL,
		.ConfirmationRespPend = NULL,
		.Arc_EOL              = FALSE
	},
	{
		.Arc_EOL = TRUE
	}
};

static const Dcm_DslDiagRespType DiagResp = {
    .DslDiagRespForceRespPendEn = TRUE,
    .DslDiagRespMaxNumRespPend =  100  /* if P2Server=100ms, so 10s totally */
};

static const Dcm_DslType Dsl = {
    .DslBuffer                    = DcmDslBufferList,
    .DslCallbackDCMRequestService = DCMRequestServiceList,
    .DslDiagResp                  = &DiagResp,
    .DslProtocol                  = &DslProtocol,
    .DslProtocolTiming            = &ProtocolTiming,
    .DslServiceRequestIndication  = DCMServiceRequestIndicationList,
    .DslSessionControl            = SessionControlList
};

const Dcm_ConfigType DCM_Config = {
    .Dsp = &Dsp,
    .Dsd = &Dsd,
    .Dsl = &Dsl
};
#endif /* USE_DCM */
